package tongwentongshu.com.app.adapter;


import android.content.Context;
import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

import tongwentongshu.com.app.R;
import tongwentongshu.com.app.bean.MyShareBean;
import tongwentongshu.com.app.bean.ShareDetailsBean;
import tongwentongshu.com.app.utils.GlideUtil;

/**
 * 文 件 名: MainBooksAdapter
 * 创 建 人: Allen
 * 创建日期: 16/12/24 19:55
 * 邮   箱: AllenCoder@126.com
 * 修改时间：
 * 修改备注：
 */
public class MyShareDetailsAdapter extends BaseQuickAdapter<ShareDetailsBean.DataBean.PersoninfoBean, BaseViewHolder> {
    private Context mContext;

    public MyShareDetailsAdapter(Context mContext, List<ShareDetailsBean.DataBean.PersoninfoBean> list) {
        super(R.layout.view_my_share_details, list);
        this.mContext = mContext;
    }

    @Override
    protected void convert(BaseViewHolder helper, ShareDetailsBean.DataBean.PersoninfoBean item) {
        if (item.getSex().equals("1")) {
            helper.setImageResource(R.id.iv_user_sex, R.drawable.mr);
        } else {
            helper.setImageResource(R.id.iv_user_sex, R.drawable.miss);
        }
        TextView status = helper.getView(R.id.tv_book_status);
        String time = "";
        switch (item.getBookstatus()) {
            case "1":
                status.setText("已预约");
                status.setTextColor(mContext.getResources().getColor(R.color.share_reading));
                time = "开始阅读时间:" + item.getRead_time();
                break;
            case "2":
                status.setText("在读");
                status.setTextColor(mContext.getResources().getColor(R.color.share_reading));
                time = "开始阅读时间:" + item.getRead_time();
                break;
            case "3":
                status.setText("已读完");
                status.setTextColor(mContext.getResources().getColor(R.color.share_read_over));
                time = "开始阅读时间:" + item.getRead_time() + "\n结束阅读时间:" + item.getDone_time();
                break;
            case "5":
                status.setText("手中空闲");
                status.setTextColor(mContext.getResources().getColor(R.color.share_reading));
                time = "开始阅读时间:" + item.getRead_time() + "\n结束阅读时间:" + item.getDone_time();
                break;
            default:
                break;
        }
        helper.setText(R.id.tv_owner_reading_time, time);
        helper.setText(R.id.tv_reader_name, "【" + item.getUser_nickname() + "】");
        helper.setText(R.id.tv_owner_reading_info, item.getShareamount() + "本分享/" + item.getReadingamount() + "本阅读");
        GlideUtil.setImage(mContext, item.getPersonheader(), R.drawable.default_graph, R.drawable.default_graph, (ImageView) helper.getView(R.id.iv_user_image));
    }


}
